package cn.yj.wx.pay.enrity;

import cn.yj.wx.pay.emums.NoticeCode;

import java.util.StringJoiner;

/**
 * 支付结果通知接收参数对象
 * @author 永健
 * @since 2021-09-23 13:52
 */
public class NoticeBody {
    private String id;

    /**
     * 通知创建时间
     */
    private String create_time;

    /**
     * 通知类型
     * 通知的类型，支付成功通知的类型为TRANSACTION.SUCCESS
     */
    private String event_type;

    /**
     * 通知数据类型
     * 通知的资源数据类型，支付成功通知为encrypt-resource
     */
    private String resource_type;


    private String summary;

    /**
     * 通知数据
     */
    private NoticeBodyResource resource;

    public boolean isSuccess(){
        return NoticeCode.SUCCESS.getCode().equals(this.getEvent_type());
    }

    public String getId() {
        return id;
    }

    public NoticeBody setId(String id) {
        this.id = id;
        return this;
    }

    public String getCreate_time() {
        return create_time;
    }

    public NoticeBody setCreate_time(String create_time) {
        this.create_time = create_time;
        return this;
    }

    public String getEvent_type() {
        return event_type;
    }

    public NoticeBody setEvent_type(String event_type) {
        this.event_type = event_type;
        return this;
    }

    public String getResource_type() {
        return resource_type;
    }

    public NoticeBody setResource_type(String resource_type) {
        this.resource_type = resource_type;
        return this;
    }

    public String getSummary() {
        return summary;
    }

    public NoticeBody setSummary(String summary) {
        this.summary = summary;
        return this;
    }

    public NoticeBodyResource getResource() {
        return resource;
    }

    public NoticeBody setResource(NoticeBodyResource resource) {
        this.resource = resource;
        return this;
    }

    @Override
    public String toString() {
        return new StringJoiner(", ", NoticeBody.class.getSimpleName() + "[", "]").add("id='" + id + "'").add(
                "create_time='" + create_time + "'").add("event_type='" + event_type + "'").add("resource_type='" + resource_type + "'").add("summary='" + summary + "'").add("resource=" + resource).toString();
    }
}
